<?php
	require_once("../../include_dao.php");
	print_r(	$_POST['PkNew'] );
print_r(		$_POST['Description']  );
print_r(	$_POST['picturePath'] );
	if(	$_POST['PkNew']  != ''  and $_POST['Description']  != '' and $_POST['picturePath'] != ''  ){
			
		
		$Description = $_POST['Description'];
		$PkNew = $_POST['PkNew'];
		$picturePath = $_POST['picturePath'];

			// Inicia la Trasaccionalidad para hacer ingresos de informacion
			$transaction = new Transaction();			
			try{
					
				// Preparo para Guardar informacion 
				$dtonews = new News();	
				$dtonews->pKNew = $PkNew;	
				$dtonews->description =  $Description;					
				$dtonews->picturePath ="./img/p_movie/". $picturePath;			
				$dtonews->active = 1;
				$dtonews->visible = 1;		
			
				/// Guarda La informacion 
				if($PkNew== 0)
					DAOFactory::getNewsDAO()->insert($dtonews);
				else 
					DAOFactory::getNewsDAO()->update($dtonews);
							
				
				//commit transaction
				$transaction->commit();
				
				// Redirecciono a la pantalla principal 
				header( 'Location: ../../News_list.php?err=40');
			}catch (Exception $e){	
			
			//	// Anulo la Transaccion
				$transaction->rollback();			
				header( 'Location: ../../News_list.php?err=31');
			}	
		
		
		}else{
		//header( 'Location: ../../News_list.php?err=13');
		}
?>